<!--添加用户表单-->
<div class="tab_edit">
    <form action="{:Url('menu_add_submit')}" method="post" id="menu_add_submit">
        <input type="hidden" name="menu_id" value="{$menu_id}"/>
        <table width="100%" class="list">
            <tr>
                <td class="t_r t_left_w">菜单编号：</td>
                <td class="t_l">
                    {$admin_menu_info['menu_id']}
                </td>
            </tr>
            <tr>
                <td class="t_r t_left_w">菜单父级编号：</td>
                <td class="t_l">
                    {$admin_menu_info['parent_id']}
                </td>
            </tr>
            <tr>
                <td class="t_r t_left_w">菜单名称：</td>
                <td class="t_l">
                    {:widget('common/Input/input',array('name',$admin_menu_info['name'],true))}
                </td>
            </tr>
            {eq name="admin_menu_info['level']" value="3"}
                <tr>
                    <td class="t_r t_left_w">菜单功能节点：</td>
                    <td class="t_l">
                        <div class="lists-tab-cont" style="width: 100%;border: 1px solid #ddd;">
                            <table width="100%" cellpadding="0" cellspacing="0" border="0">
                                <thead>
                                    <tr>
                                        <th width="15%" class="tabSort-header">菜单名称</th>
                                        <th width="20%" class="tabSort-header">控制器</th>
                                        <th width="50%" class="tabSort-header">方法名</th>
                                        <th width="15%" class="tabSort-header">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr id="node_extend">
                                        <td>{:widget("common/Input/input",array("title",null,false,false,"width:85%"))}</td>
                                        <td>{:widget("common/Input/input",array("model_name",null,false,false,"width:85%"))}</td>
                                        <td>{:widget("common/Input/input",array("action_name",null,false,false,"width:85%"))}</td>
                                        <td><a id="node_add" href="javascript:void(0);" class="blue"><b>添加</b></a></td>
                                    </tr>
                                    {foreach name="admin_node_list" item="info"}
                                        <tr class="info">
                                            <td><input type="text" name="node[title][]" style="width: 100%;" value="{$info['title']}"></td>
                                            <td><input type="text" name="node[model_name][]" style="width: 100%;" value="{$info['model_name']}"></td>
                                            <td><input type="text" name="node[action_name][]" style="width: 100%;" value="{$info['action_name']}"></td>
                                            <td><a class="del" href="javascript:void(0);" class="blue"><b>删除</b></a></td>
                                        </tr>
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>
                    </td>
                </tr>
            {/eq}
            <tr>
                <td class="t_r t_left_w">排序：</td>
                <td class="t_l">
                    {:widget('common/Input/input',array('order_by',$admin_menu_info['order_by'],true))}
                </td>
            </tr>
            <tr>
                <td class="t_r t_left_w"></td>
                <td class="t_l">
                    <div class="btn"><input type="submit" class="but_blue" value="保存信息"></div>
                </td>
            </tr>
        </table>
    </form>
</div>

<!-- JS处理 -->
<script language="javascript">
    $(function(){
        //菜单节点
        var node_tpl = {
            getTemplate : function(info){
                return  '<tr class="info"><td><input type="text" name="node[title][]" style="width: 100%;" value="' + info.title + '"></td><td><input type="text" name="node[model_name][]" style="width: 100%;" value="' + info.model_name + '"></td><td><input type="text" name="node[action_name][]" style="width: 100%;" value="' + info.action_name + '"></td><td><a class="del" href="javascript:void(0);" class="blue"><b>删除</b></a></td></tr>';
            }
        };

        //添加菜单节点
        $("a#node_add").click(function(){
            //初期化变量
            var title = $("input[name='title']");
            var title_data = $.trim(title.val());
            var model_name = $("input[name='model_name']");
            var model_name_data = $.trim(model_name.val());
            var action_name = $("input[name='action_name']");
            var action_name_data = $.trim(action_name.val());

            //判断是否数据是否存在
            if(title_data != "" && model_name_data != "" && action_name_data != "") {
                //添加到列表中
                $("tr#node_extend").after(node_tpl.getTemplate({title: title_data,model_name: model_name_data,action_name: action_name_data}));

                //清除历史状态
                title.val("");
                model_name.val("");
                action_name.val("");
            }else{
                alert("请输入菜单节点信息！");
            }
        });

        //删除关联有效区域
        $("a.del").live("click",function(){
            //删除多余数据
            $(this).parents("tr.info").remove();
        });
    });
</script>